//
//  SAAddModifyFooter.m
//  yidiantong
//
//  Created by 黄志刚 on 2020/10/9.
//
#import "SAAddModifyFooter.h"

@interface SAAddModifyFooter()

@property (nonatomic, strong) UIView *container;
@property (nonatomic, strong) UILabel *changePasswordLab;
@property (nonatomic, strong) UIImageView *arrowIcon;

@property (nonatomic, strong) UILabel *accountSafeLab;

@end

@implementation SAAddModifyFooter

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self initUI];
    }
    return self;;
}

#pragma mark - event

- (void)changePasswordAction {
    if (self.changePasswordBlock) {
        self.changePasswordBlock();
    }
}

#pragma mark - initUI

- (void)initUI {
    
    [self addSubview:self.container];
    [self addSubview:self.accountSafeLab];
    
    [self.accountSafeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kScaleNum(25));
        make.top.mas_equalTo(0);
        make.height.mas_equalTo(kScaleNum(40));
    }];
    
    [self.container mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.mas_equalTo(0);
        make.height.equalTo(self.mas_height).multipliedBy(0.5);
    }];
    
    [self.container addSubview:self.changePasswordLab];
    [self.container addSubview:self.arrowIcon];
    
    [self.changePasswordLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kScaleNum(25));
        make.top.mas_equalTo(kScaleNum(0));
        make.height.mas_equalTo(kScaleNum(40));
    }];
    
    [self.arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(kScaleNum(-25));
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(kScaleNum(8));
        make.height.mas_equalTo(kScaleNum(15));
    }];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changePasswordAction)];
    [self.container addGestureRecognizer:tap];
}

#pragma mark - lazy init

- (UIView *)container {
    if (!_container) {
        _container = [[UIView alloc] init];
        _container.backgroundColor = [UIColor whiteColor];
    }
    return _container;
}

- (UILabel *)changePasswordLab {
    if (!_changePasswordLab) {
        _changePasswordLab = [[UILabel alloc] init];
        _changePasswordLab.textColor = kBlackColor;
        _changePasswordLab.font = kFont(15);
        _changePasswordLab.text = @"修改密码";
    }
    return _changePasswordLab;
}

- (UIImageView *)arrowIcon {
    if (!_arrowIcon) {
        _arrowIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Sale_rightArrow"]];
    }
    return _arrowIcon;
}

- (UILabel *)accountSafeLab {
    if (!_accountSafeLab) {
        _accountSafeLab = [[UILabel alloc] init];
        _accountSafeLab.font = kFont(15);
        _accountSafeLab.textColor = kBlackColor;
        _accountSafeLab.text = @"账号安全";
    }
    return _accountSafeLab;
}

@end

